package _7_4;

public class Company {
	private Person managingDirector;
	private String address;
	private String faxNumber;
	private String name;
	private String phoneNumber;

	public Company() {
		this(new Person(), "", "", "", "");
	}

	public Company(Person managingDirector, String address, String faxNumber,
			String name, String phoneNumber) throws NullPointerException {
		setManagingDirector(managingDirector);
		setAddress(address);
		setFaxNumber(faxNumber);
		setName(name);
		setPhoneNumber(phoneNumber);
	}

	public String getAddress() {
		return address;
	}

	public String getFaxNumber() {
		return faxNumber;
	}

	public Person getManagingDirector() {
		return managingDirector;
	}

	public String getName() {
		return name;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void print() {
		System.out.println("Company \"" + name + "\"");
		System.out.println("Address: " + address);
		System.out.println("Fax number: " + faxNumber);
		System.out.println("Phone number: " + phoneNumber);
	}

	public void setAddress(String address) throws NullPointerException {
		if (address != null) {
			this.address = address;
		} else {
			this.address = "";
			throw new NullPointerException(
					"The String argument \"address\" is a null pointer.");
		}
	}

	public void setFaxNumber(String faxNumber) throws NullPointerException {
		if (faxNumber != null) {
			this.faxNumber = faxNumber;
		} else {
			this.faxNumber = "";
			throw new NullPointerException(
					"The String argument \"faxNumber\" is a null pointer.");
		}
	}

	public void setManagingDirector(Person managingDirector)
			throws NullPointerException {
		if (managingDirector != null) {
			this.managingDirector = managingDirector;
		} else {
			throw new NullPointerException(
					"The String argument \"managingDirector\" is a null pointer.");
		}
	}

	public void setName(String name) throws NullPointerException {
		if (name != null) {
			this.name = name;
		} else {
			this.name = "";
			throw new NullPointerException(
					"The String argument \"name\" is a null pointer.");
		}
	}

	public void setPhoneNumber(String phoneNumber) throws NullPointerException {
		if (phoneNumber != null) {
			this.phoneNumber = phoneNumber;
		} else {
			this.phoneNumber = "";
			throw new NullPointerException(
					"The String argument \"phoneNumber\" is a null pointer.");
		}
	}
}
